<?php
// $Id: matchdart-eventlist.tpl.php 182 2010-03-13 17:49:35Z mwi.nor $

/**
 * @file matchdart-eventlist.tpl.php
 * Default theme implementation to display a list of events and series.
 *
 * Available variables:
 * - $events: An array of events and series to display. It is keyed to the
 *   numeric id's of all child events and series.
 * - $event_id: Event id for the current event. Parent to all items within
 *   the $events array.
 *
 * Each $event in $events contains:
 * - $event->is_series: Is TRUE if the event can contain other events. Is
 *   FALSE if the event can contain only matches.
 * - $event->depth: How deep the event is in the current hierarchy.
 * - $event->zebra: 'even' or 'odd' string used for row class.
 * - $event->name: The name of the event.
 * - $event->link: The URL to link to this event.
 * - $event->description: The description of this event.
 * - $event->new_topics: True if the event contains unread posts.
 * - $event->new_url: A URL to the event's unread posts.
 * - $event->new_text: Text for the above URL which tells how many new posts.
 * - $event->old_topics: A count of posts that have already been read.
 * - $event->num_posts: The total number of posts in the event.
 * - $event->last_reply: Text representing the last time a event was posted or
 *   commented in.
 *
 * @see template_preprocess_matchdart_eventlist()
 * @see theme_matchdart_eventlist()
 */
?>
<table id="forum-<?php print $event_id; ?>">
  <thead>
    <tr>
      <th><?php print t('Event'); ?></th>
      <th><?php print t('Players');?></th>
      <th><?php print t('Matches'); ?></th>
      <th><?php print t('Last update'); ?></th>
    </tr>
  </thead>
  <tbody>
  <?php foreach ($events as $child_id => $event): ?>
    <tr id="forum-list-<?php print $child_id; ?>" class="<?php print $event->zebra; ?>">
      <td <?php print $event->is_series ? 'colspan="4" class="container"' : 'class="forum"'; ?>>
        <?php /* Enclose the contents of this cell with X divs, where X is the
               * depth this forum resides at. This will allow us to use CSS
               * left-margin for indenting.
               */ ?>
        <?php print str_repeat('<div class="indent">', $event->depth); ?>
          <div class="name"><a href="<?php print $event->link; ?>"><?php print $event->name; ?></a></div>
          <?php if ($event->description): ?>
            <div class="description"><?php print $event->description; ?></div>
          <?php endif; ?>
        <?php print str_repeat('</div>', $event->depth); ?>
      </td>
      <?php if (!$event->is_series): ?>
        <td class="topics"><?php print $event->num_players ?></td>
        <td class="posts"><?php print $event->num_matches ?>
          <?php if ($event->new_matches): ?>
            <br />
            <a href="<?php print $event->new_url; ?>"><?php print $event->new_text; ?></a>
          <?php endif; ?>
        </td>
        <td class="last-reply"><?php print $event->last_update ?></td>
      <?php endif; ?>
    </tr>
  <?php endforeach; ?>
  </tbody>
</table>
